<%@ page import="java.time.LocalDateTime" %>
<%@ page import="java.time.format.DateTimeFormatter" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>reg</title>
    <link rel="stylesheet" href="css/index.css">
</head>

<body>
<%
    //session
    if(session.getAttribute("snum") == null){
        session.setAttribute("snum",1);
    }else{
        int t = Integer.parseInt(session.getAttribute("snum").toString());
        session.setAttribute("snum",++t);
    }
%>
<h1>session(${sessionScope.snum})</h1>

<%
    //application
    if(application.getAttribute("snum") == null){
        application.setAttribute("snum",1);
    }else{
        int t = Integer.parseInt(application.getAttribute("snum").toString());
        application.setAttribute("snum",++t);
    }
%>
<h1>application(${applicationScope.snum})</h1>
<h1 id="app"></h1>
<script>
    setInterval(()=>{
        fetch("/app").then(e=>e.text()).then(res=>{
            document.querySelector('#app').innerHTML = res
        }).catch(e=>console.log(e));
    },1000)
</script>
</body>
</html>
